package SparkGraphXInAction

import org.apache.spark._
import org.apache.log4j.{Level, Logger}
import org.apache.spark.SparkContext
import org.apache.spark.SparkContext._
import org.apache.spark.SparkConf
import org.apache.spark.graphx._
import org.apache.spark.graphx.Graph._
import org.apache.spark.rdd.RDD
import org.apache.spark.graphx.util.GraphGenerators

/**
  * Created by Administrator on 2017/4/24 0024.
  * 个性化PageRank找出最重要的关联论文
  */
object PersonalizedPageRank {
  def main(args: Array[String]): Unit = {
    //设置运行环境
    val conf = new SparkConf().setAppName("SimpleGraphX").setMaster("local")
    val sc = new SparkContext(conf)
    val g = GraphLoader.edgeListFile(sc,"cit-HepTh.txt")
    val xx = g.personalizedPageRank(9207016,0.00001)
      .vertices
      .filter(_._1 != 9207016)
      .reduce((a, b) => if (a._2 > b._2) a else b)
    println(xx.asInstanceOf[AnyRef].getClass.getSimpleName)
    println(xx)
  }
}
